<?php
/*
Autor: Marek Křivan
(c) 2009 
*/

#funkce fora

$get_template = $db->query("SELECT template FROM {prefix}forum_konfigurace LIMIT 1");
$get_template = $get_template->fetch_array();

self::header('style', $GLOBALS['url'] . 'components/com_forum/templates/'.$get_template[0].'.css');
self::header('style', $GLOBALS['url'] . 'plugins/content/TipsX3.css');
self::header('script', $GLOBALS['url'] . 'plugins/content/TipsX3.js');

function over_cislo($sifra,$cislo) {
                if($sifra != md5($cislo)) {
                        $chyba = "&nbsp;- číslo bylo špatně opsáno<br />";
                        return $chyba;
                }
        }                
function orez_retezec_2($retezec) {
                $retezec = $GLOBALS['db']->real_escape_string($retezec);
                return $retezec;
        }
function overeni_vyplneni($promenna, $nazev) {
                $vysledek = "";
                if(empty($promenna)) { $vysledek = "&nbsp;- povinné pole <b>".$nazev."</b> nebylo vyplněno<br />"; }
                return $vysledek;
        }
 function je_ban($ip) {
   $query = $GLOBALS['db']->query("SELECT * FROM " . $GLOBALS['db_prefix'] ."forum_ip_ban WHERE ip = '$ip';");
   while ($ban = $query->fetch_array()) 
                if($ban != 0) {
                        return "&nbsp;- máte zakázáno vkládat příspěvky a zakládat témata - kontaktujte admin fóra<br />";
                }
        }
function nahodne_cislo() { 
   $cisla = Array("0" => "nula", "1" => "jedna", "2" => "dvě", "3" => "tři", "4" => "čtyři", "5" => "pět", "6" => "šest", "7" => "sedm", "8" => "osm", "9" => "devět");
  $i = mt_rand(0,9); $cislo = $cisla[$i]; $sifra = md5($i);
  $vysledek[cislo] = $cislo; $vysledek[sifra] = $sifra;
  return $vysledek;
        }
        

$epoch = date("U");
                if(!isset($_COOKIE[cas])) {
                        setcookie("cas", $epoch, $epoch+3600*24*365);
                } elseif(!isset($_COOKIE[fora])) {
                        $query = $GLOBALS['db']->query("SELECT id FROM " . $GLOBALS['db_prefix'] ."forum_fora WHERE posledni2 > '$_COOKIE[cas]';");
                        $unread_fora = Array();
                        while ($row = $query->fetch_array()) {
                                $unread_fora[] = $row[id];
                        }        
                        $unread_fora2 = implode("|", $unread_fora);
                        setcookie("fora", $unread_fora2, $epoch+900);
                }

                setcookie("cas", $epoch, $epoch+3600*24*365);

$query = $GLOBALS['db']->query("SELECT id, display_name FROM ".$GLOBALS['db_prefix']."users WHERE id = '".$_SESSION['id']."'");
        while ($data = $query->fetch_array()) {
        $user = $data['display_name'];
        }  
        
require_once ('.'.DIR_SEP.'libs'.DIR_SEP.'hash.php');

switch($q[1]){
	case '':
	    include('./components/com_forum/files/forum.php');
	    include('./components/com_forum/files/stats.php');
	break;
	
	case 'theme':
	    include('./components/com_forum/files/theme.php');
	    include('./components/com_forum/files/stats.php');
	break;
	case 'dues':
	     include('./components/com_forum/files/dues.php');
	     include('./components/com_forum/files/stats.php');
	break;

case 'action_ban':
	    include('./components/com_forum/action/ban.php');
	break;
	
	case 'action_edit':
	    include('./components/com_forum/action/edit.php');
	break;
	
case 'action_presun':
	    include('./components/com_forum/action/presun.php');
	break;

case 'action_zamk_odemk':
	    include('./components/com_forum/action/zamk_odemk.php');
	break;

case 'tema_delete':
	    include('./components/com_forum/action/delete.php');
	break;

case 'prispevek_delete':
	    include('./components/com_forum/action/delete.php');
	break;
	
case 'edit_titulek':
	    include('./components/com_forum/action/edit_titulek.php');
	break;
	
case 'action_dulezite':
	    include('./components/com_forum/action/dulezite.php');
	break;

case 'edit_tema':
	    include('./components/com_forum/action/edit_tema.php');
	break;

default:
	    require('./templates/404.php');
	break;
}

?>